import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialVO, MaterialForm, MaterialQuery } from '@/api/demo/boardMaterial/types';

/**
 * 查询看板素材列表
 * @param query
 * @returns {*}
 */

export const listMaterial = (query?: MaterialQuery): AxiosPromise<MaterialVO[]> => {
  return request({
    url: '/system/material/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询看板素材详细
 * @param materialId
 */
export const getMaterial = (materialId: string | number): AxiosPromise<MaterialVO> => {
  return request({
    url: '/system/material/' + materialId,
    method: 'get'
  });
};

/**
 * 新增看板素材
 * @param data
 */
export const addMaterial = (data: MaterialForm) => {
  return request({
    url: '/system/material',
    method: 'post',
    data: data
  });
};

/**
 * 修改看板素材
 * @param data
 */
export const updateMaterial = (data: MaterialForm) => {
  return request({
    url: '/system/material',
    method: 'put',
    data: data
  });
};

/**
 * 删除看板素材
 * @param materialId
 */
export const delMaterial = (materialId: string | number | Array<string | number>) => {
  return request({
    url: '/system/material/' + materialId,
    method: 'delete'
  });
};
